package online.flowerinsnow.minecraft.bukkit.manhunt.manager;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import online.flowerinsnow.minecraft.bukkit.manhunt.Manhunt;
import online.flowerinsnow.minecraft.bukkit.manhunt.util.MessageUtils;

public final class RecipeManager {
    private RecipeManager() {
    }

    public static void register() {
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "golden_head"), RecipeManager.GHEAD);
        recipe.shape("ggg", "ghg", "ggg");
        recipe.setIngredient('g', Material.GOLD_INGOT);
        recipe.setIngredient('h', Material.PLAYER_HEAD);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "coal_pickaxe"), COAL_PICKAXE);
        recipe.shape("aaa", " b ", " b ");
        recipe.setIngredient('a', Material.COAL);
        recipe.setIngredient('b', Material.STICK);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_chicken"), FAST_COOK_CHICKEN);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.CHICKEN);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_porkchop"), FAST_COOK_PORKCHOP);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.PORKCHOP);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_mutton"), FAST_COOK_MUTTON);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.MUTTON);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_beef"), FAST_COOK_BEEF);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.BEEF);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_rabbit"), FAST_COOK_RABBIT);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.RABBIT);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_cod"), FAST_COOK_COD);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.COD);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_salmon"), FAST_COOK_SALMON);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.SALMON);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "fast_cook_kelp"), FAST_COOK_KELP);
        recipe.shape("aaa", "aba", "aaa");
        recipe.setIngredient('a', Material.KELP);
        recipe.setIngredient('b', Material.COAL);
        Bukkit.addRecipe(recipe);

        recipe = new ShapedRecipe(new NamespacedKey(Manhunt.getInstance(), "batch_craft_bread"), BATCH_CRAFT_BREAD);
        recipe.shape("aaa");
        recipe.setIngredient('a', Material.HAY_BLOCK);
        Bukkit.addRecipe(recipe);
    }

    public static final ItemStack GHEAD;
    public static final ItemStack COAL_PICKAXE;
    public static final ItemStack FAST_COOK_CHICKEN;
    public static final ItemStack FAST_COOK_PORKCHOP;
    public static final ItemStack FAST_COOK_MUTTON;
    public static final ItemStack FAST_COOK_BEEF;
    public static final ItemStack FAST_COOK_RABBIT;
    public static final ItemStack FAST_COOK_COD;
    public static final ItemStack FAST_COOK_SALMON;
    public static final ItemStack FAST_COOK_KELP;
    public static final ItemStack BATCH_CRAFT_BREAD;
    static {
        GHEAD = new ItemStack(Material.GOLDEN_APPLE);
        ItemMeta meta = GHEAD.getItemMeta();
        //noinspection ConstantConditions
        meta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        meta.setDisplayName(MessageUtils.parseColor("&5金头"));
        GHEAD.setItemMeta(meta);

        COAL_PICKAXE = new ItemStack(Material.STONE_PICKAXE);
        meta = COAL_PICKAXE.getItemMeta();
        //noinspection ConstantConditions
        meta.addEnchant(Enchantment.DIG_SPEED, 1, true);
        meta.setDisplayName("§f煤炭镐");
        COAL_PICKAXE.setItemMeta(meta);

        FAST_COOK_CHICKEN = new ItemStack(Material.COOKED_CHICKEN, 8);
        FAST_COOK_PORKCHOP = new ItemStack(Material.COOKED_PORKCHOP, 8);
        FAST_COOK_MUTTON = new ItemStack(Material.COOKED_MUTTON, 8);
        FAST_COOK_BEEF = new ItemStack(Material.COOKED_BEEF, 8);
        FAST_COOK_RABBIT = new ItemStack(Material.COOKED_RABBIT, 8);
        FAST_COOK_COD = new ItemStack(Material.COOKED_COD, 8);
        FAST_COOK_SALMON = new ItemStack(Material.COOKED_SALMON, 8);
        FAST_COOK_KELP = new ItemStack(Material.DRIED_KELP, 8);
        BATCH_CRAFT_BREAD = new ItemStack(Material.BREAD, 9);
    }
}
